#define _GNU_SOURCE
#include <getopt.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

#define SET 1
#define UNSET 0

int main(int argc,char *argv[])
{
	int opt;
        
//	unsigned char FLAG_CR = UNSET;
	unsigned char FLAG_TS = UNSET;	/*TIER SPACE*/
	unsigned char FLAG_TI = UNSET;	/*TIER INFORMATION*/
	unsigned char FLAG_CP = UNSET;	/*SHOW CURRENT POLICY*/
	unsigned char FLAG_AP = UNSET;	/*ASSIGN POLICY*/ 
	unsigned char FLAG_RP = UNSET;	/*ASSIGN RELOCATION POLICY*/
	unsigned char FLAG_E  = UNSET;	/*OHSM ENABLED*/
	unsigned char FLAG_D  = UNSET;	/*OHSM DISABLED*/
	unsigned char FLAG_RT = UNSET;	/*REASSIGN ALLOC POLICY*/
	unsigned char FLAG_RR = UNSET;	/*REASSIGN RELOC POLICY*/

	struct option longopts[] = {
//	{"create",1,NULL,'b'},
		{"tierspace", 1, NULL, 't'},
		{"tierinfo", 1, NULL, 'i'},
		{"currpoly", 1, NULL, 'c'},
		{"allocpoly", 1, NULL, 'a'},
		{"relocpoly", 1, NULL, 'r'},
		{"enabled", 1, NULL, 'e'},
		{"disabled", 1, NULL, 'd'},
		{"reassgnpoly", 1, NULL, 'x'},
		{"reassgnreloc", 1, NULL, 'y'},
		{0,0,0,0}
	};
	
	while((opt=getopt_long(argc, argv, ":t:i:c:a:r:e:d:x:y", longopts, NULL)) != -1)   
	{
		switch(opt) {
		
		case 't':
			printf ("option %c\n", opt);
			FLAG_TS = SET;
			printf ("This gives tier space");
			printf ("\nArguments are %s\n", optarg);
			break;

		case 'i':
			printf ("option %c\n", opt);
	                FLAG_TI = SET;
			printf ("This gives tier information");
			printf ("\nArgument are %s\n", optarg);
			break;

		case ':':
			printf ("Missing Argumnet");
			break;
	
		case 'c':
			printf ("option %c\n", opt);
			FLAG_CP = SET;
			printf ("Argument are %s\n", optarg);
			printf ("\nThis gives the current policy enforced");
			break;
        
		case 'a':
			printf ("option %c\n", opt);
                	FLAG_AP = SET;
			printf ("Argument are %s\n", optarg);
			printf ("\nThis gives the allocation policy");
			break;
        
		case 'r':
			printf ("option %c\n", opt);
			FLAG_RP = SET;
			printf ("Argument is %s\n", optarg);
			printf ("\nThis gives the relocation policy");
			break;

		case 'e':
			printf ("option %c\n", opt);
			FLAG_E = SET;
			printf ("This will enable the OHSM");
			printf ("\nArgument is %s\n", optarg);
			break;
	         
		case 'd':
			printf ("option %c\n", opt);
			FLAG_D = SET;
			printf ("This gives disable the OHSM"); 
			printf ("\nArgument is %s\n", optarg);
			break;

		case '?':
			printf ("Missing option %c", optopt);
			break;         

		case 'x':
			printf ("option %c\n", opt);
			FLAG_RT = SET;
			printf ("This will reassign the allocation policy");
			printf ("\nArgument is %s\n", optarg);
			break;

		case 'y':
			printf ("option %c\n", opt);
			FLAG_RR = SET;
			printf ("Argument is %s\n", optarg);
			printf ("\nThis will reassign the realloc policy"); 
	 		break;
		}
	}

	if(FLAG_E == SET){
		//Call the ioctl
	}
	if(FLAG_D == SET){
		//Call the ioctl 
	}	
        if(FLAG_TS == SET){
               //Call the ioctl	
        } 
        if(FLAG_TI == SET){
               //Call the ioctl
	}
        
	exit (0);
}        
